<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1.Object.defineProperty</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <!-- 准备好一个容器-->
    <div id="demo">

    </div>
</body>

<script type="text/javascript">
    //阻止 vue 在启动时生成生产提示。
    Vue.config.productionTip = false
    let number = 18;
    let person = {
        name: '峰峰',
        gender: '男',
    }
    Object.defineProperty(person, 'age', {
        // value: 18, //指定属性的值
        //enumerable: true, //标识属性是否可枚举,默认值是false,
        // writable: true, //标识属性是否可被修改,默认值是false
        // configurable: true, //标识属性是否可以被删除,默认值是false

        get() {
            return number
        },
        set(value) {
            number = value
        }
    })
    for (const key in person) {
        // console.log(key, person[key])
    }
    // console.log(person)
</script>

</html>